<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="viewport" content="height=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
    <title></title>
    <style>
        *{margin:0;padding:0}
        .add_order{
            width:100%;
            height:auto;
            overflow: hidden;
        }
        .regTop{
            width: 100%;
            line-height: 30px;
            text-align: center;
            background: #50B4F9;
            overflow: hidden;
        }
        .regTop a{
            width: 30%;
            line-height: 30px;
            display: block;
            float: left;
            text-align: left;
            font-weight: 700;
            text-decoration: none;
        }
        .regTop span{
            width: 70%;
            line-height: 30px;
            display: block;
            float: right;
            font-weight: 700;
            text-align: left;
        }
        .content{
            width:100%;
            height:auto;
            text-align: center;
            margin:5% auto;
        }
        .message{
            width:100%;
            height:auto;
            margin:5% auto;
        }
        .message input{
            width:99%;
            display: block;
            border:2px dotted #ccc;
            height:30px;
            text-indent: 5%;
            border-radius: 25px;
        }
        button{
            width:99%;
            text-align: center;
            line-height: 30px;
            border-radius: 30px;
            border:none;
            background: #50B4F9;
            margin:5% auto;
        }
        .order_info{
            width:100%;
            height:auto;
            overflow: hidden;
            margin:0 auto;
        }
    </style>
</head>
<body>
    <div class="add_order">
        <div class="regTop">
            <span>&nbsp;&nbsp;查单</span>
            <a class="back" href="index.html">&lt;返回</a>
        </div>
        <div class="content">
            <div action="">
                <div class="message">
                    <input type="text"  name="query_str" placeholder="收货人/电话/商品"  required/>
                    <button class="submit" type="submit" onclick="searchOrder('{:url("index/index/get_data")}')">查单</button>
                </div>

            </div>
            <div class="order_info">

            </div>
        </div>
    </div>
</body>
</html>
<script src="__STATIC__/js/jquery.min.js"></script>
<script src="__STATIC__/layer/layer.js"></script>
<script>
    function searchOrder(url)
    {
        var data = $("input[name=query_str]").val();
        if(!data){
            layer.msg('请输入收货人/电话/商品',{'icon':5});
            return false;
        }
        $.ajax({
            url:url,
            type:'post',
            data:{'query_str':data},
            success:function(d){
                var d = JSON.parse(d);
                if(d.type==0){
                    layer.msg(d.msg,{'icon':5});
                }
                if(d.type==1){
                    layer.msg(d.msg,{'icon':5});
                }
                if(d.type==2){
                    layer.msg(d.msg,{'icon':5});

                }
                add_html(d);
            },
            error:function(d){
                layer.msg('出错了~~~',{'icon':5});
                window.location.href="";
            }
        })
    }

    function add_html(obj,type)
    {
        var html = '';
        if(obj.type==0){
            html+="<div style='margin:2px;font-size:16px;'>"+"<span>"+"没有运单信息"+"</span>"+"</div>";
        }else if(obj.type==1){
            html+="<div style='margin:2px;font-size:16px;'>"+"<span>"+obj.data.goods_name+"</span>"+"&nbsp;<span>运单号："+obj.data.order_no+"</span>"+"</div>";
        }else if(obj.type==2){
            for(var i=0;i<obj.data.length;i++)
            {
                html+="<div style='margin:2px;font-size:16px;'>"+"<span>"+obj.data[i].goods_name+"</span>"+"&nbsp;<span>运单号："+obj.data[i].order_no+"</span>"+"</div>";
            }
        }

        $("div.order_info").html('').html(html);
    }
</script>